<include file="Public/header"/>
<include file="Public/menu"/>
<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak={$ak}"></script>-->
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            店铺配置
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 店铺配置</a></li>
            <li class="active">修改店铺</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">修改店铺</h3>

                        <div class="box-tools">

                            <div class="btn-group pull-right" style="margin-right: 10px">
                                <a href="/manage/store/index" class="btn btn-sm btn-default"><i class="fa fa-list"></i>&nbsp;店铺列表</a>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form action="{:U('Admin/Storesetup/index')}" method="post" accept-charset="UTF-8" id="form"
                          class="form-horizontal" pjax-container="">
                        <div class="box-body">
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">店铺名称</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <div class="form-control no-border">{$store['local_name']}</div>
                                    </div>
                                </div>
                            </div>
                            <div class="box-body">
                                <div class="form-group 1">
                                    <label class="col-sm-2 control-label">店铺logo</label>
                                    <div class="col-sm-6">
                                        <input type="file" id="image" data-max-file-count="1" />
                                        <input type="hidden" id="image_action"/>
                                    </div>
                                </div>
                            </div>
                            <div for="image" class="form-group 1">
                                <label class="col-sm-2 control-label"></label>
                                <div class="col-sm-6" style="margin-left: 16px; color: #da2424">* 必须大于宽高300px*300px (用于店铺分享的logo)</div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">配送区域(公里)</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="text" name="area_dispatch" value="{$store.area_dispatch}"
                                               class="form-control" placeholder="配送区域(公里) 例如: 3">
                                        <span class="input-group-addon">km</span>
                                    </div>
                                </div>
                            </div>


                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">电话</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input id="tel" type="text" name="tel" value="{$store.tel}" class="form-control"
                                               placeholder="电话">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">手机</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input id="mobile" type="text" name="mobile" value="{$store.mobile}"
                                               class="form-control" placeholder="手机">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">自提备注</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <textarea type="text" name="ziti_remark" class="form-control">{$store.ziti_remark}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">温馨提示</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <textarea id="specialContent">{$store.wenxintishi}</textarea>
                                        <input type="hidden" name="wenxintishi" value="">
                                    </div>
                                </div>
                            </div>

                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">购物车承诺文字描述</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="text" name="maxPriceDesc" value="{$store['maxPriceDesc']}"
                                               class="form-control" placeholder="全场满59元免运费">
                                    </div>
                                </div>
                            </div>


                            <div class="form-group 1">
                                <label class="col-sm-2 control-label">服务承诺</label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                        <input type="text" name="services[]" value="{$store['services'][0]}"
                                               class="form-control" placeholder="输入关键字">
                                        <span class="input-group-addon addkey"><i class="fa fa-fw fa-plus"></i></span>
                                    </div>
                                </div>
                            </div>




                            <if condition="count($store['services']) gt 1">
                                <volist name="store['services']" id="vo" offset="1">
                                    <div class="form-group 1">
                                        <label class="col-sm-2 control-label"></label>
                                        <div class="col-sm-6">
                                            <div class="input-group">
                                                <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                                <input type="text" name="services[]" value="{$vo}" class="form-control"
                                                       placeholder="输入关键字">
                                                <span class="input-group-addon delkey"><i class="fa fa-fw fa-minus"></i></span>
                                            </div>
                                        </div>
                                    </div>
                                </volist>
                            </if>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="col-sm-2">

                            </div>
                            <div class="col-sm-6">

                                <div class="btn-group pull-left">
                                    <button type="submit" id="submit" class="btn btn-info pull-right">保存</button>
                                </div>

                            </div>

                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>

            </div>
        </div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<!--上传插件-->
<link rel="stylesheet" href="/Public/admin/fileinput/fileinput.min.css">
<script src="/Public/admin/fileinput/fileinput.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"></script>
<script data-exec-on-popstate>

    $(function () {

        var ue = UE.getEditor('specialContent', {
            autoHeight: false,
            initialFrameHeight: 500,
        });

        $('.box-body').on('click', '.addkey', function () {
            var html = '';
            html += '<div class="form-group 1"><label class="col-sm-2 control-label"></label><div class="col-sm-6"><div class="input-group"><span class="input-group-addon"><i class="fa fa-pencil"></i></span>';
            html += '<input type="text" name="services[]" value="" class="form-control" placeholder="输入关键字">';
            html += '<span class="input-group-addon delkey"><i class="fa fa-fw fa-minus"></i></span></div></div></div>';
            $('.box-body').append(html);
        });

        $('.box-body').on('click', '.delkey', function () {
            $(this).parent().parent().parent('.form-group').remove();
        })

        //  表单提交
        $('input[name=is_byself]').on('change', function () {
            if (this.value == '0') {
                var default_name = $('input[name=myexpress]').data('default');
                $('input[name=myexpress]').val(default_name);
            }
        });
        $("#form").validate({
            rules: {
                mobile: {
                    isMobile: true
                },
                tel: {
                    isPhone: true
                },
                area_dispatch: {
                    required: true,
                    isPrice: true,
                    min: 0.01
                },
                ziti_remark: {
                    minlength: 2,
                    maxlength: 50
                }
            },
            messages: {
                area_dispatch: {
                    required: "请输入配送公里"
                },
                ziti_remark: {
                    minlength: "自提备注最少2个字符",
                    maxlength: "自提备注最多可输入50个字符"
                }
            },
            submitHandler: function (form) {
                var content = ue.getContent();
                $('input[name=wenxintishi]').val(content);
                form.submit();   //提交表单
            }
        });
    });



    // 上传图片js
    $("#image").fileinput({
                overwriteInitial: true,
                dropZoneEnabled: false,
                uploadUrl: '/Admin/upload/index/"',
                language: 'zh',
                showRemove: false,
                maxFileCount: 1,
                browseClass: 'btn btn-primary btn-docup',
                showPreview: true,
                uploadClass: 'btn btn-default btn-docup',
                allowedFileTypes: ["image"],
                browseLabel: "添加图片",
                uploadLabel: "上传图片",
                initialCaption:"{$store['local_log']}",
            <if condition = "(!empty($store['local_log']))">
            initialPreview:['<img src="/Uploads/{$store.local_log}" class="file-preview-image">']
    </if>
    }).on("fileuploaded", function (event, data, previewId, index) {
        var response = data.response;
        if (data.jqXHR.status == 200) {
            // ajax 成功返回数据写入
            $('.file-preview-frame').eq(index).append("<input class='abc' type='hidden' name='local_log' value='"+response+"'>");
        }
    });
    $("#image").on('filecleared', function(event) {
        $("#image_action").val(1);
    });
    $('#Continent').change(function () {
        //获取下拉框选中项的index属性值
        var selectIndex = $('#Continent').get(0).selectedIndex;
        if (selectIndex !=0) {
            $('.img-link').css('display','none');
        }else {
            $('.img-link').css('display','block');
        }
    });
</script>
